package com.itheima;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Demo1 {
    public static void main(String[] args) {
        Date date = new Date();
        long longTime = date.getTime();


        Date date1 = new Date(longTime + 1999L * 12 * 30*12*30*30);
        System.out.println(date1);


        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String format = sdf.format(date1);
        System.out.println(format);

        String s = "2022-01-01 12:30:30";
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date2 = null;
        try {
            date2 = sdf2.parse(s);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        System.out.println(date2);
        try {
            date2 =sdf2.parse(s);
        }catch (ParseException e){
            e.printStackTrace();
        }

    }
}
